<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>获取和设置参数</title>
</head>
<style>
    #elme{
        min-height: 20px;
        background-color: red;
    }
</style>
<body>
    <div id="elem" title="这是一个标题"></div>
    <div>
        <button>获取title</button>
        <button>设置新title</button>
    </div>
    <script src="jquery-3.6.3.js"></script>
    <script>
        $("button:nth-child(1)").click(function(){
            let tit = $ ("#elem").attr("title")
            alert(tit)
        })
        $("button:nth-child(2)").click(function(){
            $ ("#elem").attr("title","我是新设置的title")
        })
    </script>
</body>
</html>